
package com.zsrt.day20170505.homework.ch02;


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.Reader;

import org.junit.Test;


public class CompareTool {

	@Test
	public void testName() throws Exception {
		
		Node head = new Node();
		Stack stack = new Stack();
		stack.setHead(head);
		
		
		File file = new File("src/com/zsrt/lianxi/L.java");
		
		Reader reader = new FileReader(file);
		
		BufferedReader bReader = new BufferedReader(reader);
		int i=0;
		String string;
		while((string=bReader.readLine()) != null){
			
				if(string != null){
					
					if(string.contains("{")){
						i++;
						Node node = new Node(i);
						stack.push(node);
					}
					if(string.contains("}")){
						i = i-1;
						stack.pop();
						//System.out.println(stack.pop());
					}
				}else{
					break;
				}
		}
		//stack.printStack();
		System.out.println(i);
		if(i==0){
			System.out.println("括号匹配成功");
		}else{
			System.out.println("括号匹配失败");
		}
	}
}
